package org.example.ui.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.example.application.RecycleBinService;
import org.example.domain.model.entity.url.req.RecycleBinPageReq;
import org.example.domain.model.entity.url.req.RecycleBinReq;
import org.example.web.result.ResultInfo;
import org.springframework.web.bind.annotation.*;


@RestController
@RequiredArgsConstructor
@Tag(name = "回收站管理" ,description = "回收站管理")
@RequestMapping("/api/recycle-bin/v1")
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    @PostMapping("/save")
    @Operation(summary = "保存回收站")
    public ResultInfo saveRecycleBin(@RequestBody RecycleBinReq recycleBinReq) {
        recycleBinService.saveRecycleBin(recycleBinReq);
        return ResultInfo.success();
    }


    @GetMapping("/page")
    @Operation(summary = "分页查询回收站短链接")
    public ResultInfo recycleBinPage(RecycleBinPageReq recycleBinPageReq) {
        return ResultInfo.success(recycleBinService.recycleBinPage(recycleBinPageReq));
    }

    @PostMapping("/recover")
    @Operation(summary = "恢复短链接")
    public ResultInfo recoverRecycleBin(@RequestBody RecycleBinReq recycleBinReq) {
        recycleBinService.recoverRecycleBin(recycleBinReq);
        return ResultInfo.success();
    }


    @PostMapping("/remove")
    @Operation(summary = "移除短链接")
    public ResultInfo removeRecycleBin(@RequestBody RecycleBinReq recycleBinReq) {
        recycleBinService.removeRecycleBin(recycleBinReq);
        return ResultInfo.success();
    }
}
